<% cache_unless page_builder_enabled?, [*spree_storefront_base_cache_scope.call(section), current_store] do %>
  <footer
    id='footer'
    <% unless current_theme_preview %>
    data-turbo-permanent
    <% end %>>
    <div style='<%= section_styles(section) %>'>
      <div class="page-container">
        <div class="flex gap-0 md:gap-6 md:flex-row flex-col">
          <div class="flex justify-center flex-grow py-2 md:py-0 border-b md:border-none lg:w-60">
            <%= render 'spree/shared/logo', logo: section.logo.attached? ? section.logo : current_header_logo %>
          </div>
          <div class="grid grid-cols-1 lg:grid-cols-4 grow w-full">
            <% section.blocks.includes(:links).each do |block| %>
              <div class="flex-grow gap-1 flex flex-col py-6 md:py-0 border-b md:border-none border-default lg:mb-6">
                <div <%= block_attributes(block) %>>
                  <h3 class="text-sm py-2"><%= block.preferred_label %></h3>
                  <ul class="uppercase text-sm tracking-wider !leading-4 flex flex-col gap-1">
                    <% block.links.each do |link| %>
                      <li class='py-2'>
                        <%= page_builder_link_to link, target: ('_blank' if link.open_in_new_tab), rel: ('noopener noreferrer' if link.open_in_new_tab), **link_attributes(link, as_html: false) do %>
                          <%= link.label %>
                        <% end %>
                      </li>
                    <% end %>
                  </ul>
                </div>
              </div>
            <% end %>
          </div>
          <div class="flex-grow gap-4 flex flex-col justify-between lg:w-60">
            <div class="gap-1 flex flex-col py-6 md:py-0">
              <h3 class="text-sm py-2"><%= Spree.t(:follow_us) %></h3>
              <div class="flex flex-wrap gap-2 max-w-48 py-2">
                <% cache spree_storefront_base_cache_scope.call(current_store) do %>
                  <% Spree::Store::SUPPORTED_SOCIAL_NETWORKS.each do |media| %>
                    <% if current_store.send(media).present? %>
                      <%= link_to current_store.send("#{media}_link") do %>
                        <%= render "spree/shared/icons/#{media.gsub('_', '-')}" %>
                        <span class='hidden'><%= current_store.send("#{media}_handle") %></span>
                      <% end %>
                    <% end %>
                  <% end %>
                <% end %>
              </div>
            </div>
          </div>
        </div>
        <div class="flex justify-end w-full"></div>
      </div>
    </div>
    <div class="text-sm" style="color: <%= section.preferred_copyright_text_color %>; background-color: <%= section.preferred_copyright_background_color %>">
      <div class='page-container py-2 flex justify-center gap-2'>
        <span>© <%= Time.now.year %>
        <a href='/'><%= current_store.name %></a>. <%= Spree.t(:all_rights_reserved) %>.</span>
        <span>
          Powered by <a href='https://spreecommerce.org' target="_blank" rel="follow" class="underline">Spree Commerce</a>
        </span>
      </div>
    </div>
  </footer>
<% end %>
